/* 
 * File:   Ray.h
 * Author: brady
 *
 * Created on June 13, 2011, 7:01 PM
 */

#ifndef RAY_H
#define	RAY_H
#include <core/Vector3D.h>
#include <vector>
#include <stack>

using namespace std;

class Ray {
public:
    Ray();

    /**
     * Constructor
     * @param origin Vector3D location of the origin of the ray
     * @param direction Vector3D indicating the ray direction relative to the origin
     * @param recursionLimit the maximum number of times the ray may be reflected or refracted
     */
    Ray(const Vector3D& origin, const Vector3D& direction, int recursionLimit);

    Ray(const Vector3D& origin, const Vector3D& direction);

    virtual ~Ray();
    /**
     * Accessor for the Ray origin
     * @return Vector3D with the Ray origin
     */
    const Vector3D& getOrigin() const {return origin;}

    /**
     * Accessor for the Ray direction
     * @return Vector3D with the Ray direction relative to the Ray origin
     */
    const Vector3D& getDirection() const {return direction;}

    /**
     * Follows the Ray from it's origin to the Vector3D point that lies
     * tVal units away toward the Ray direction
     * @param tVal the distance to follow the Ray
     * @return the Vector3D point at origin + tVal * the ray's unit direction
     */
    Vector3D follow(double tVal) const;

    /**
     * Returns a Ray with the same origin and refractiveIndex data, but reflects the direction
     * @param normal the normal of the surface off which the Ray is reflecting
     * @return
     */
    Ray reflect(const Vector3D& normal, const Vector3D& hitPoint) const;

    /**
     * Returns a Ray with the same origin and refractiveIndex data, but refracts the direction
     * based on the current refractive index
     * @param normal the normal of the surface off which the Ray is refracting
     * @return
     */
    Ray refract(const Vector3D& normal, const Vector3D& hitPoint, double newRefractiveIndex) const;

    int recursionLimit;
    int batchNumber;
    int sampleNumber;
    

private:
    Vector3D origin, direction;

};

#endif	/* RAY_H */

